package com.zsm.eblog.controller;

import com.zsm.eblog.pojo.Article;
import com.zsm.eblog.pojo.ResponseResult;
import com.zsm.eblog.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Author : ZSM
 * Time :  2024/08/17
 */
@RestController
public class ArticleController {
    @Autowired
    private ArticleService articleService;

    @GetMapping("/notes/{type}")
    public ResponseResult studyNotes(@PathVariable String type) {
        List<Article> data = articleService.list(type);
        ResponseResult result = new ResponseResult();
        result.setData(data);
        result.setStatus("ok");
        result.setMsg("获取成功");
        return result;
    }

    @GetMapping("/detail/{id}")
    public ResponseResult detail(@PathVariable Integer id) {
        Article article = articleService.queryById(id);
        ResponseResult result = new ResponseResult();
        result.setData(article);
        result.setStatus("ok");
        result.setMsg("获取成功");
        return result;
    }
}
